package com.codi.bus.core.dao.impl;

import com.codi.base.dao.BaseDAOImpl;
import com.codi.bus.core.dao.BankLimitDao;
import com.codi.bus.core.domain.BankLimit;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository("bankLimitDao")
public class BankLimitDaoImpl extends BaseDAOImpl<BankLimit> implements BankLimitDao{

    @Override
    public int add(BankLimit bankLimit) {
        return this.insert(generateStatement("insertSelective"), bankLimit);
    }

    @Override
    public BankLimit selectOne(int id) {
        return this.getObject(generateStatement("selectByPrimaryKey"), id);
    }

    @Override
    public int deleteById(int id) {

        return this.delete(generateStatement("deleteByPrimaryKey"), id);
    }

    @Override
    public int update(BankLimit bankLimit) {
        return this.update(generateStatement("updateByPrimaryKeySelective"), bankLimit);
    }

    @Override
    public List<BankLimit> selectAll() {
        return this.findList(generateStatement("selectAll"));
    }

    @Override
    public List<BankLimit> selectAllByState() {
        return this.findList(generateStatement("selectAllByState"));
    }

    @Override
    public BankLimit selectByChannelAndCode(String code, String channel) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("channel", channel);

        return this.getObject(generateStatement("selectByChannelAndCode"), map);
    }
}
